<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //* 相当于 >=0 可以出现0次或者很多次
        var reg = /^a*$/;
        console.log(reg.test(''));
        console.log(reg.test('a'));
        console.log(reg.test('aaaa'));
        console.log('-----------------');

        //+ 相当于 >=1 可以出现一次或者很多次
        var reg1 = /^a+$/;
        console.log(reg1.test(''));
        console.log(reg1.test('a'));
        console.log(reg1.test('aaaa'));
        console.log('-----------------');

        //? 相当于 1 || 0
        var reg2 = /^a?$/;
        console.log(reg2.test(''));
        console.log(reg2.test('a'));
        console.log(reg2.test('aaaa'));
        console.log('-----------------');

        //{3}  重复3次
        var reg3 = /^a{3}$/;
        console.log(reg3.test(''));
        console.log(reg3.test('a'));
        console.log(reg3.test('aaaa'));
        console.log(reg3.test('aaa'));
        console.log('-----------------');

        //{3,} 大于等于3
        var reg4 = /^a{3,}$/;
        console.log(reg4.test(''));
        console.log(reg4.test('a'));
        console.log(reg4.test('aaaa'));
        console.log(reg4.test('aaa'));
        console.log('-----------------');

        //{3,6} 大于等于3次，并且小于等于16
        var reg5 = /^a{3,6}$/;
        console.log(reg5.test(''));
        console.log(reg5.test('a'));
        console.log(reg5.test('aaaa'));
        console.log(reg5.test('aaa'));
        console.log(reg5.test('aaaaaaa'));
        console.log('-----------------');
    </script>
</body>
</html>